/*
这里定义输入法相关的接口和宏，结构体
*/
#ifndef LV_IME_FUNC_H
#define LV_IME_FUNC_H

#include "lvgl/lvgl.h"
#include "lvgl/src/extra/widgets/keyboard/lv_keyboard.h"

// 键盘布局
enum{
        LV_selfdefine_start=3,      
        LV_KEYPAD_MODE_PINYIN,        
        LV_KEYPAD_MODE_JAPANESE,
        LV_KEYPAD_MODE_RUSSIA_LOW,
        LV_KEYPAD_MODE_KOREAN,
        LV_KEYPAD_MODE_VIETNAMESE,
        LV_KEYPAD_MODE_ARABIC,
        LV_KEYPAD_MODE_PERSIAN,
       // LV_KEYPAD_MODE_RUSSIA_UP,      
        LV_KEYPAD_MODE_MAX   
};



#define LV_EARTH_ICON "\xee\x9a\x89"

#define CAND_STR_MAX_LEN  16
#define LV_100ASK_PINYIN_IME_CAND_TEXT_NUM          10
#define LV_USE_100ASK_PINYIN_IME 1
//参考100ask 词典结果，保留名称
typedef struct
{
    const char * const py;      //对照表第一列
    const char * const py_mb;   //对照表第二列
    const char * const py_hz;   //对照表第三列
}lv_100ask_dict_t;


typedef   int   (*ime_init_keypad_map)(lv_obj_t *kb);
typedef   void  (*ime_init_dict)(lv_obj_t * obj, lv_100ask_dict_t * dict);
typedef   void  (*ime_input_proc)(lv_obj_t * obj);
typedef   char* (*ime_search_matching)(lv_obj_t * obj, char * strInput_py_str, uint16_t * cand_num);
typedef   void  (*ime_select_event_handler)(lv_event_t * e);

//输入法插件结构体
typedef struct{
    int                 keypad_code;         //LV_KEYPAD_MODE_RUSSIA_LOW
    lv_100ask_dict_t *  dict;                //输入法结构体
    ime_init_keypad_map init_kb_map;         //初始化map
    ime_init_dict       init_dict;           //初始化词典
    ime_input_proc      input_proc;          //输入处理程序
    char * btnm_sel[LV_100ASK_PINYIN_IME_CAND_TEXT_NUM + 3];
    //ime_search_matching search_matching;     //匹配候选词
    //ime_select_event_handler select_event_handler;  //事件响应

}ime_plugin_t;


ime_input_proc ime_get_input_pro_func(int mode_code);


//对外接口
/*
初始化多语言插件列表
*/
/**
 * 初始化多语言插件列表
 * @param obj  pointer to a ime object
 * @return     0:成功 -1：失败
 */

int lv_ime_init_multi_plugin(lv_obj_t * obj);


/**********************
 * GLOBAL PROTOTYPES
 **********************/
lv_obj_t * lv_ime_create(lv_obj_t * parent);

/*=====================
 * Setter functions
 *====================*/

/**
 * Set the dictionary of ime input method.
 * @param obj  pointer to a ime object
 * @param dict pointer to a ime dictionary
 */
void lv_ime_set_dict(lv_obj_t * obj, lv_100ask_dict_t * dict);


/*=====================
 * Getter functions
 *====================*/

/**
 * Set the dictionary of ime input method.
 * @param obj  pointer to a ime object
 * @return     pointer to the keyboard
 */
lv_obj_t * lv_ime_get_kb(lv_obj_t * obj);


/**
 * Set the dictionary of ime input method.
 * @param obj  pointer to a ime object
 * @return     pointer to the ime candidate panel
 */
lv_obj_t * lv_ime_get_cand_panel(lv_obj_t * obj);


/**
 * Set the dictionary of ime input method.
 * @param obj  pointer to a ime object
 * @return     pointer to the ime dictionary
 */
lv_100ask_dict_t * lv_ime_get_dict(lv_obj_t * obj);



#endif